#define _CRT_SECURE_NO_WARNINGS 1
#define _CRT_SECURE_NO_WARNINGS 1
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
void reverse(char* left, char* right)
{
    while (left < right)
    {
        char tmp = *left;
        *left = *right;
        *right = tmp;
        left++;
        right--;
    }
}
void PrintA(char* start, char* end)
{
    printf(" ");
}
int main()
{
    char arr[50] = { 0 };
    gets(arr);
    int len = strlen(arr) - 1;
    reverse(arr, arr + len);
    char* start = arr;
    char* now = arr;
    while (*now != '\0')
    {
        while (*now != ' ' && *now != '\0')
            now++;
        reverse(start, now - 1);
        start = now + 1;
        if (*now != '\0')
            now++;
    }
    char* start1 = arr;
    char* end1 = arr;
    char* now1 = arr;
    while (*now1 != '\0')
    {
        if (*now1 == ' ')
        {
            start1 = now1;
            while (*now1 == ' ' && *now1 != '\0')
                now1++;
            end1 = now1;
            PrintA(start1, end1);
        }
        printf("%c", *now1);
        now1++;
    }
    return 0;
}